import http from '@/utils/http';

import {postAjax} from '@/utils/axios';

/**
 * 删除区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const removeWork = (params: any) => {
  return http.delete('bus/work/remove', {params});
}

/**
 * 获取系统用户列表
 * @param params
 * @returns {*|Promise<any>}
 */
export const getWorkList = (params?: any) => {
  return http.get('bus/work/list', {params});
}

export const simplePublishList = (params?: any) => {
  return http.get('bus/work/simplePublishList', {params});
}

export const simpleStartList = (params?: any) => {
  return http.get('bus/work/simpleStartList', {params});
}


export const publishList = (params?: any) => {
  return http.get('bus/work/publishList', {params});
}


export const publishAdnStartList = (params?: any) => {
  return http.get('bus/work/publishAdnStartList', {params});
}

export const startList = (params?: any) => {
  return http.get('bus/work/startList', {params});
}

export const finishList = (params?: any) => {
  return http.get('bus/work/finishList', {params});
}

export const historyList = (params?: any) => {
  return http.get('bus/work/historyList', {params});
}



/**
 * 保存修改区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const updateWork = (params: any) => {
  return http.put('bus/work/edit', params);
}

/**
 * 保存新增区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const addWork = (params: any) => {
  return http.post('bus/work/add', params);
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getById = (params: any) => {
  return http.get('bus/work/' + params.id);
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getBeforePublish = (params: any) => {
  return http.get('bus/work/beforePublish/' + params.id);
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getAreaConfirm = (params: any) => {
  return http.get('bus/region/getAreaConfirm/' + params.workId);
}


export const areaConfirm = (params: any) => {
  return http.get('bus/work/areaConfirm/' + params.workId);
}



export const getWorkCategoryTree = (params?: any) => {
  return http.get('bus/work/getWorkCategoryTree',{params});
}

export const getStartWorkCategoryTree = (params?: any) => {
  return http.get('bus/work/getStartWorkCategoryTree',{params});
}

export const getHistoryWorkCategoryTree = (params?: any) => {
  return http.get('bus/work/getHistoryWorkCategoryTree',{params});
}





/**
 * 验证区域名称是否唯一
 * @param params
 * @returns {*|Promise<any>}
 */
export const publishWork = (params: any) => {

  return postAjax('bus/work/publish', params);
}

/**
 * 验证区域名称是否唯一
 * @param params
 * @returns {*|Promise<any>}
 */
export const checkNameUnique = (params: any) => {
  params.loading = false;
  return http.post('bus/work/checkNameUnique', params);
}

export const workOverview = (workId: any) => {
  return http.post(`bus/work/overview/${workId}`);
}


